<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
      xmlns:ui="http://java.sun.com/jsf/facelets"
      xmlns:p="http://primefaces.org/ui"
      xmlns:h="http://java.sun.com/jsf/html"
      xmlns:f="http://java.sun.com/jsf/core">

    <body>

        <ui:composition template="./TemplatePrincipal.xhtml">

            <ui:define name="top">
                <p:panel>
                    <p:clock mode="server" autoSync="true" pattern="HH:mm:ss dd/MM/yy" />
                </p:panel>
            </ui:define>

            <ui:define name="left">
                <p:panel>
                    <f:view>
                        <h:form>
                            <p:commandButton id="newButton" ajax="false" value="New" action="AssignScholarshipCreateEdit" actionListener="#{assignScholarshipBean.prepareNew}">
                                <p:tooltip for="newButton" value="Assign new Scholarship"/>
                            </p:commandButton>
                            <p:commandButton value="Back" action="PrincipalMenu" id="backMenuButton" ajax="false">
                                <p:tooltip for="backMenuButton" value="Back to principal menu..."/>
                            </p:commandButton>
                        </h:form>
                    </f:view>

                </p:panel>
            </ui:define>

            <ui:define name="content">
                <p:panel>
                    <f:view>
                        <h:form>
                            <h1><h:outputText value="Assigned Scholarship List"/></h1>
                            <p:dataTable value="#{assignScholarshipBean.listAssignedScholarship}" var="item">
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Date"/>
                                    </f:facet>
                                    <h:outputText value="#{item.date}">
                                        <f:convertDateTime pattern="MM/dd/yyyy" />
                                    </h:outputText>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Scholarship holder"/>
                                    </f:facet>
                                    <h:outputText value="#{item.idStudent}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Scholarship type"/>
                                    </f:facet>
                                    <h:outputText value="#{item.idScholarship}"/>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <h:outputText value="Delete"/>
                                    </f:facet>
                                    <center>
                                        <p:commandButton value="Delete" 
                                                         action="AssignScholarshipConfirm" 
                                                         actionListener="#{assignScholarshipBean.prepareRemove}"
                                                         id="deleteUButton" ajax="false"/>
                                        <p:tooltip for="deleteUButton" value="Delete Scholarship awarded..."/>
                                    </center>
                                </p:column>
                                <p:column>
                                    <f:facet name="header">
                                        <p:outputLabel value="Edit"/>
                                    </f:facet>
                                    <center>
                                        <p:commandButton value="Edit" action="AssignScholarshipCreateEdit" 
                                                         actionListener="#{assignScholarshipBean.prepareEdit}"
                                                         id="editCButton" ajax="false">
                                            <p:tooltip for="editCButton" value="Edit scholarship awarded ..."/>
                                            <f:setPropertyActionListener value="#{item}" target="#{assignScholarshipBean.assignScholarship}"/>
                                        </p:commandButton>
                                    </center>
                                </p:column>
                            </p:dataTable>
                        </h:form>
                    </f:view>
                </p:panel>
            </ui:define>
        </ui:composition>
    </body>
</html>
